package com.ee.chat.api.controller;


import com.ee.chat.api.service.IVipService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("vip")
public class VipController {
    private Logger log = LoggerFactory.getLogger(VipController.class);

    @Resource
    IVipService vipService;

    /**
     * 获取
     * @Author Shane
     * @Date 2019/9/421:10
     * @param type  类型，0-微信支付宝  1-苹果内购
     * @return
     **/
    @RequestMapping("getVipPackages")
    public Result getVipPackages(@RequestParam String token, @RequestParam(required = false, defaultValue = "0") Integer type){
        try {
            return vipService.getVipPackages(token, type);
        } catch (Exception e){
            log.error("【获取vip套餐列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 购买VIP
     * @Author Shane
     * @Date 2019/9/511:08
     * @param vipId     vip套餐id
     * @param payWay    充值类型，0-微信  1-支付宝  2-苹果内购
     * @return
     **/
    @RequestMapping("buyVip")
    public Result buyVip(@RequestParam String token, @RequestParam Integer vipId, @RequestParam Integer payWay){
        try {
            return vipService.buyVip(token, vipId, payWay);
        } catch (Exception e){
            log.error("【购买vip套餐错误】", e);
        }
        return Result.returnFailure();
    }

}
